﻿using System;


namespace HeroDream
{
    /// <summary>
    /// 护送任务，有一定概率会得到商人的小费
    /// </summary>
 sealed   class ConvoyTask : Task
    {
        public ConvoyTask(int send) : base(send)
        {
            Random random = new Random(DateTime.Now.Millisecond + send);
            id = random.Next(1, 100);
            des = $"【护送任务{id}】——护送商队";
            coin = random.Next(10, 100);
            time = random.Next(2, 6);
            type = TaskType.Convoy;
        }

        /// <summary>
        /// 方法的多态：通过重写基类的虚方法，来实现不同的方法定义和实现，是为方法的多态。
        /// </summary>
        /// <param name="hero"></param>
        public override void TaskRun(Hero hero)
        {
            base.TaskRun(hero);
       
            Random random = new Random(DateTime.Now.Millisecond);
            int rand = random.Next(0, 100);
            if (rand > 50)
            {
                int pcoin = random.Next(20, 100);
                Console.WriteLine($"你的护送任务受到了商人的赏识，金币增加{pcoin}");
                hero.Coin = hero.Coin + pcoin;
            }
        }
    }
    
}
